package com.nidu.demo.dict.executor.command;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.cola.dto.Response;
import com.nidu.demo.dict.gateway.DictTypeGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 字典类型删除命令执行器
 *
 * @author auto
 */
@Component
@RequiredArgsConstructor
public class DictTypeDeleteCmdExe {

    private final DictTypeGateway gateway;

    public Response execute(Long id) {
        if(id != null){
            gateway.deleteById(id);
        }
        return Response.buildSuccess();
    }

    public Response execute(Set<Long> ids){
        if(!CollUtil.isEmpty(ids)){
            gateway.deleteByIds(ids);
        }
        return Response.buildSuccess();
    }
} 